# -*- coding: utf-8 -*-
"""
Date: 2021-12-06
Author: J z
"""

import os
import yaml

from utils.dict_utils import dict_merge

try:
    _base_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), r'base_game.yml')
    with open(_base_file_path, 'r') as f:
        base_conf = yaml.load(f.read())

except IOError as e:
    print "base_game.yml not exist!"
    base_conf = {}

except Exception as e:
    print e
    with open('base_game.yml', 'r') as f:
        base_conf = yaml.load(f.read())

server_conf = {}

try:
    _file_path = 'game.yml'
    with open(_file_path, 'r') as f:
        server_conf = yaml.load(f.read())
except IOError as e:
    print "game.yml not exist!"

except Exception as e:
    print e
    with open('game.yml', 'r') as f:
        server_conf = yaml.load(f.read())


conf = dict_merge(base_conf, server_conf)


is_debug = conf.get('dev', {}).get('is_debug', False)


if is_debug:
    print '===================== RUN IN DEBUG MODE ====================='
